﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar.Metro;
using DevComponents.DotNetBar;
using System.Diagnostics;
using DevComponents.AdvTree;
using DevComponents.DotNetBar.Metro.ColorTables;
using GUI.View;

namespace GUI.View
{
    public partial class Form3 : DevComponents.DotNetBar.Metro.MetroAppForm
    {
        StartControl _StartControl = null; // Start control displayed on startup
        AppCommands _Commands = null; // All application commands
        public string username;
        public Form3()
        {
            InitializeComponent();
            _Commands = new AppCommands();

            _Commands.ToggleStartControl = new Command(components);
            _Commands.ToggleStartControl.Executed += new EventHandler(ToggleStartControlExecuted);
            //Danh Sách khach hang
            _Commands.ListKhachHangCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.ListKhachHangCommands.New.Executed += NewDanhSachKhachHangControl;
            _Commands.ListKhachHangCommands.Cancel = new Command(components);
            _Commands.ListKhachHangCommands.Cancel.Executed += CancelDanhSachKhachHang;


            //thong tin dia oc
            _Commands.ListTiepNhanDiaOcCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.ListTiepNhanDiaOcCommands.New.Executed += NewDanhSachDiaOcControl;
            _Commands.ListTiepNhanDiaOcCommands.Cancel = new Command(components);
            _Commands.ListTiepNhanDiaOcCommands.Cancel.Executed += CancelDanhSachDiaOc;

            //about
            _Commands.AboutCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.AboutCommands.New.Executed += NewAboutControl;
            _Commands.AboutCommands.Cancel = new Command(components);
            _Commands.AboutCommands.Cancel.Executed += CancelFrmAbout;

            ////Chi Tiết khách hàng
            _Commands.ChiTietKhachHangCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.ChiTietKhachHangCommands.New.Executed += NewDetailPatientControl;
            _Commands.ChiTietKhachHangCommands.Cancel = new Command(components);
            _Commands.ChiTietKhachHangCommands.Cancel.Executed += CancelDetailPatient;

            //Lập phiếu Dang ky
            _Commands.LapPhieuDangkyDiaOcCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.LapPhieuDangkyDiaOcCommands.New.Executed += NewLapPhieuDangKyControl;
            _Commands.LapPhieuDangkyDiaOcCommands.Cancel = new Command(components);
            _Commands.LapPhieuDangkyDiaOcCommands.Cancel.Executed += CancelLapPhieuDangKy;

            //Lap phieu thu

            _Commands.LapPhieuThuTienCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.LapPhieuThuTienCommands.New.Executed += NewLapThuTienControl;
            _Commands.LapPhieuThuTienCommands.Cancel = new Command(components);
            _Commands.LapPhieuThuTienCommands.Cancel.Executed += CancelLapPhieuThu;

            //Tìm kiếm
            _Commands.TimKiemCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.TimKiemCommands.New.Executed += NewTimKiemControl;
            _Commands.TimKiemCommands.Cancel = new Command(components);
            _Commands.TimKiemCommands.Cancel.Executed += CancelFormSearch;

            //Tìm kiếm nâng cao
            _Commands.TimKiemNangCaoCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.TimKiemNangCaoCommands.New.Executed += NewTimKiemNangCaoControl;
            _Commands.TimKiemNangCaoCommands.Cancel = new Command(components);
            _Commands.TimKiemNangCaoCommands.Cancel.Executed += CancelFormSearchDetail;

            ////Lập hóa đơn
            //_Commands.LapHoaDonCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            //_Commands.LapHoaDonCommands.New.Executed += NewLapHoaDonControl;
            //_Commands.LapHoaDonCommands.Cancel = new Command(components);
            //_Commands.LapHoaDonCommands.Cancel.Executed += CancelFormBill;


            ////Hóa đơn thanh toán
            //_Commands.HoaDonThanhToanCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            //_Commands.HoaDonThanhToanCommands.New.Executed += NewHoaDonThanhToanControl;
            //_Commands.HoaDonThanhToanCommands.Cancel = new Command(components);
            //_Commands.HoaDonThanhToanCommands.Cancel.Executed += CancelFormPayBill;

            //Thống Kê
            _Commands.ThongKeCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.ThongKeCommands.New.Executed += NewThongKeControl;
            _Commands.ThongKeCommands.Cancel = new Command(components);
            _Commands.ThongKeCommands.Cancel.Executed += CancelReport;

            //Tùy Chỉnh
            _Commands.TuyChinhCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.TuyChinhCommands.New.Executed += NewOptionControl;
            _Commands.TuyChinhCommands.Cancel = new Command(components);
            _Commands.TuyChinhCommands.Cancel.Executed += CancelOption;

            //Thông tin
            _Commands.ThongTinCommands.New = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.ThongTinCommands.New.Executed += NewInfomationControl;
            _Commands.ThongTinCommands.Cancel = new Command(components);
            _Commands.ThongTinCommands.Cancel.Executed += CancelInfomation;


            this.SuspendLayout();
            _StartControl = new StartControl();
            _StartControl.Commands = _Commands;
            this.Controls.Add(_StartControl);
            _StartControl.BringToFront();
            _StartControl.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Right;
            this.ResumeLayout(false);

        }
        KhachHangControl _listKhachHang = null;
        void NewDanhSachKhachHangControl(object sender, EventArgs e)
        {
            Debug.Assert(_listKhachHang == null);
            _Commands.ListKhachHangCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            _listKhachHang = new KhachHangControl();
            _listKhachHang.Commands = _Commands;
            this.ShowModalPanel(_listKhachHang, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }

        private void CancelDanhSachKhachHang(object sender, EventArgs e)
        {
            // Simply close client entry form "dialog"
            Debug.Assert(_listKhachHang != null);
            CloseDanhSachKhachHang();
        }
        private void CloseDanhSachKhachHang()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.ListKhachHangCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(_listKhachHang, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            _listKhachHang.Commands = null;
            _listKhachHang.Dispose();
            _listKhachHang = null;
        }

        //Dia Oc

        TiepNhanDiaOcControl _listDiaOc = null;
        //ListPatient listPatient = null;
        void NewDanhSachDiaOcControl(object sender, EventArgs e)
        {
            Debug.Assert(_listDiaOc == null);
            _Commands.ListTiepNhanDiaOcCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            _listDiaOc = new TiepNhanDiaOcControl();
            _listDiaOc.Commands = _Commands;
            this.ShowModalPanel(_listDiaOc, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }

        private void CancelDanhSachDiaOc(object sender, EventArgs e)
        {
            Debug.Assert(_listDiaOc != null);
            CloseDanhSachDiaOc();
        }
        private void CloseDanhSachDiaOc()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.ListTiepNhanDiaOcCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(_listDiaOc, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            _listDiaOc.Commands = null;
            _listDiaOc.Dispose();
            _listDiaOc = null;
        }

        // phieu thu
        LapPhieuThuTien _lapphieuthu = null;

        void NewLapThuTienControl(object sender, EventArgs e)
        {
            Debug.Assert(_lapphieuthu == null);
            _Commands.LapPhieuThuTienCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            _lapphieuthu = new LapPhieuThuTien();
            _lapphieuthu.Commands = _Commands;
            this.ShowModalPanel(_lapphieuthu, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }

        private void CancelLapPhieuThu(object sender, EventArgs e)
        {
            Debug.Assert(_lapphieuthu != null);
            CloseLapPhieuThu();
        }

        private void CloseLapPhieuThu()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.LapPhieuThuTienCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(_lapphieuthu, DevComponents.DotNetBar.Controls.eSlideSide.Left);

            //string[] values = _lapphieudangkydiaoc.lblNgayKham.Text.Trim().Split('/');
            //_listDiaOc.dateTime_BenhNhan.Value = DateTime.Now;
            //_listDiaOc.dateTime_BenhNhan.Value = new DateTime(Int32.Parse(values[2]), Int32.Parse(values[1]), Int32.Parse(values[0]));

            _lapphieuthu.Commands = null;
            _lapphieuthu.Dispose();
            _lapphieuthu = null;
        }
        ///////////////////////////////
        About about = null;
        void NewAboutControl(object sender, EventArgs e)
        {
            Debug.Assert(about == null);
            _Commands.AboutCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            about = new About();
            about.Commands = _Commands;
            this.ShowModalPanel(about, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }

        private void CancelFrmAbout(object sender, EventArgs e)
        {
            Debug.Assert(about != null);
            CloseFrmAbout();
        }
        private void CloseFrmAbout()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.AboutCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(about, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            about.Commands = null;
            about.Dispose();
            about = null;
        }
        /////////////////////////////

        //Tìm kiếm
        TimKiem _search = null;

        void NewTimKiemControl(object sender, EventArgs e)
        {
            Debug.Assert(_search == null);
            _Commands.TimKiemCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            _search = new TimKiem();
            _search.Commands = _Commands;
            this.ShowModalPanel(_search, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }



        private void CancelFormSearch(object sender, EventArgs e)
        {
            // Simply close client entry form "dialog"
            Debug.Assert(_search != null);
            CloseFormSearch();
        }
        private void CloseFormSearch()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.TimKiemCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(_search, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            _search.Commands = null;
            _search.Dispose();
            _search = null;
        }

        //Tìm kiếm nâng cao

        TimKiemNangCao _searchDetail = null;

        void NewTimKiemNangCaoControl(object sender, EventArgs e)
        {
            Debug.Assert(_searchDetail == null);
            _Commands.TimKiemNangCaoCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            _searchDetail = new TimKiemNangCao();
            _searchDetail.Commands = _Commands;
            this.ShowModalPanel(_searchDetail, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }



        private void CancelFormSearchDetail(object sender, EventArgs e)
        {
            // Simply close client entry form "dialog"
            Debug.Assert(_searchDetail != null);
            CloseFormSearchDetail();
        }
        private void CloseFormSearchDetail()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.TimKiemNangCaoCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(_searchDetail, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            _searchDetail.Commands = null;
            _searchDetail.Dispose();
            _searchDetail = null;
        }

        //Lập Hóa đơn

        //LapHoaDonControl _bill = null;
        //void NewLapHoaDonControl(object sender, EventArgs e)
        //{
        //    Debug.Assert(_search == null);
        //    _Commands.LapHoaDonCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
        //    _bill = new LapHoaDonControl();
        //    _bill.Commands = _Commands;
        //    this.ShowModalPanel(_bill, DevComponents.DotNetBar.Controls.eSlideSide.Left);
        //    if (!_StartControl.Visible)
        //        _StartControl.SlideOutButtonVisible = false;
        //}

        //private void CancelFormBill(object sender, EventArgs e)
        //{
        //    // Simply close client entry form "dialog"
        //    Debug.Assert(_bill != null);
        //    CloseFormBill();
        //}
        //private void CloseFormBill()
        //{
        //    if (!_StartControl.Visible)
        //        _StartControl.SlideOutButtonVisible = true;

        //    _Commands.LapHoaDonCommands.New.Enabled = true; // Enable new client command

        //    this.CloseModalPanel(_bill, DevComponents.DotNetBar.Controls.eSlideSide.Left);
        //    _bill.Commands = null;
        //    _bill.Dispose();
        //    _bill = null;
        //}

        ////hóa đơn thanh toán


        //HoaDonThanhToan _hoadonthanhtoan = null;
        //void NewHoaDonThanhToanControl(object sender, EventArgs e)
        //{
        //    Debug.Assert(_hoadonthanhtoan == null);
        //    _Commands.HoaDonThanhToanCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
        //    _hoadonthanhtoan = new HoaDonThanhToan();
        //    _hoadonthanhtoan.Commands = _Commands;
        //    _hoadonthanhtoan._hoten = _bill._hoten;
        //    _hoadonthanhtoan._mabenhnhan = _bill._mabenhnhan;
        //    _hoadonthanhtoan._ngaykham = _bill._ngaykham;
        //    _hoadonthanhtoan._tinhtrangthanhtoan = _bill._tinhtrangthanhtoan;
        //    this.ShowModalPanel(_hoadonthanhtoan, DevComponents.DotNetBar.Controls.eSlideSide.Left);
        //    if (!_StartControl.Visible)
        //        _StartControl.SlideOutButtonVisible = false;
        //}

        //private void CancelFormPayBill(object sender, EventArgs e)
        //{
        //    // Simply close client entry form "dialog"
        //    Debug.Assert(_hoadonthanhtoan != null);
        //    CloseFormPayBill();

        //}
        //private void CloseFormPayBill()
        //{
        //    if (!_StartControl.Visible)
        //        _StartControl.SlideOutButtonVisible = true;

        //    _Commands.HoaDonThanhToanCommands.New.Enabled = true; // Enable new client command

        //    this.CloseModalPanel(_hoadonthanhtoan, DevComponents.DotNetBar.Controls.eSlideSide.Left);
        //    string[] values = _hoadonthanhtoan.txtNgayKham.Text.Trim().Split('/');

        //    _bill.dateTime_NgayKham.Value = DateTime.Now;

        //    _bill.dateTime_NgayKham.Value = new DateTime(Int32.Parse(values[2]), Int32.Parse(values[1]), Int32.Parse(values[0]));

        //    _hoadonthanhtoan.Commands = null;
        //    _hoadonthanhtoan.Dispose();


        //    _hoadonthanhtoan = null;
        //}

        //Thống kê

        ThongKe _report = null;
        void NewThongKeControl(object sender, EventArgs e)
        {
            Debug.Assert(_report == null);
            _Commands.ThongKeCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            _report = new ThongKe();
            _report.Commands = _Commands;
            this.ShowModalPanel(_report, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }

        private void CancelReport(object sender, EventArgs e)
        {
            // Simply close client entry form "dialog"
            Debug.Assert(_report != null);
            CloseReport();
        }
        private void CloseReport()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.ThongKeCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(_report, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            _report.Commands = null;
            _report.Dispose();
            _report = null;
        }

        //Tùy chỉnh

        TuyChinh _option = null;
        void NewOptionControl(object sender, EventArgs e)
        {
            Debug.Assert(_option == null);
            //
            _Commands.TuyChinhCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            _option = new TuyChinh();
            _option.usersname = username;
            _option.Commands = _Commands;
            this.ShowModalPanel(_option, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }

        private void CancelOption(object sender, EventArgs e)
        {
            // Simply close client entry form "dialog"
            Debug.Assert(_option != null);
            CloseOption();
        }
        private void CloseOption()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.TuyChinhCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(_option, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            _option.Commands = null;
            _option.Dispose();
            _option = null;
        }


        //THong tin
        ThongTin _infomation = null;
        void NewInfomationControl(object sender, EventArgs e)
        {
            Debug.Assert(_infomation == null);
            _Commands.ThongTinCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            _infomation = new ThongTin();
            _infomation.Commands = _Commands;
            this.ShowModalPanel(_infomation, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }

        private void CancelInfomation(object sender, EventArgs e)
        {
            // Simply close client entry form "dialog"
            Debug.Assert(_infomation != null);
            CloseInfomation();
        }
        private void CloseInfomation()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.ThongTinCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(_infomation, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            _infomation.Commands = null;
            _infomation.Dispose();
            _infomation = null;
        }

        ChiTietKhachHangControl _detail = null;

        void NewDetailPatientControl(object sender, EventArgs e)
        {
            Debug.Assert(_infomation == null);
            _Commands.ChiTietKhachHangCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            _detail = new ChiTietKhachHangControl();
            _detail.Commands = _Commands;
            this.ShowModalPanel(_detail, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }

        private void CancelDetailPatient(object sender, EventArgs e)
        {
            Debug.Assert(_detail != null);
            CloseDetailPatient();
        }

        private void CloseDetailPatient()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.ChiTietKhachHangCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(_detail, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            _detail.Commands = null;
            _detail.Dispose();
            _detail = null;
        }
        //phieu dang ky
        DangKyBanDiaOc _lapphieudangkydiaoc = null;

        void NewLapPhieuDangKyControl(object sender, EventArgs e)
        {
            Debug.Assert(_lapphieudangkydiaoc == null);
            _Commands.LapPhieuDangkyDiaOcCommands.New.Enabled = false; // Disable new client command to prevent re-entrancy
            _lapphieudangkydiaoc = new DangKyBanDiaOc();
            _lapphieudangkydiaoc.Commands = _Commands;
            this.ShowModalPanel(_lapphieudangkydiaoc, DevComponents.DotNetBar.Controls.eSlideSide.Left);
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = false;
        }

        private void CancelLapPhieuDangKy(object sender, EventArgs e)
        {
            Debug.Assert(_lapphieudangkydiaoc != null);
            CloseLapPhieuDangKy();
        }

        private void CloseLapPhieuDangKy()
        {
            if (!_StartControl.Visible)
                _StartControl.SlideOutButtonVisible = true;

            _Commands.LapPhieuDangkyDiaOcCommands.New.Enabled = true; // Enable new client command

            this.CloseModalPanel(_lapphieudangkydiaoc, DevComponents.DotNetBar.Controls.eSlideSide.Left);

            //string[] values = _lapphieudangkydiaoc.lblNgayKham.Text.Trim().Split('/');
            //_listDiaOc.dateTime_BenhNhan.Value = DateTime.Now;
            //_listDiaOc.dateTime_BenhNhan.Value = new DateTime(Int32.Parse(values[2]), Int32.Parse(values[1]), Int32.Parse(values[0]));

            _lapphieudangkydiaoc.Commands = null;
            _lapphieudangkydiaoc.Dispose();
            _lapphieudangkydiaoc = null;
        }



        #region Command Execution


        private void ToggleStartControlExecuted(object sender, EventArgs e)
        {
            _StartControl.IsOpen = !_StartControl.IsOpen;


        }



        #endregion

        #region UI Code
        void StartControl_Click(object sender, EventArgs e)
        {
            _StartControl.IsOpen = false;
        }

        protected override void OnLoad(EventArgs e)
        {
            _StartControl.lblAdmin.Text = "Xin chào " + username;
            UpdateControlsSizeAndLocation();
            base.OnLoad(e);
        }

        private Rectangle GetStartControlBounds()
        {
            int captionHeight = metroShell1.MetroTabStrip.GetCaptionHeight() + 2;
            Thickness borderThickness = this.GetBorderThickness();
            return new Rectangle((int)borderThickness.Left + 65, captionHeight, this.Width - (int)borderThickness.Horizontal, this.Height - captionHeight - 1);
        }
        private void UpdateControlsSizeAndLocation()
        {
            if (_StartControl != null)
            {
                if (!_StartControl.IsOpen)
                    _StartControl.OpenBounds = GetStartControlBounds();
                else
                    _StartControl.Bounds = GetStartControlBounds();
                if (!IsModalPanelDisplayed)
                    _StartControl.BringToFront();
            }

        }
        #endregion
    }
}